<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-8-2
 * Time: 下午1:01
 */
/**
 * @var \yii\web\View $this
 * @var \yii\base\Model $model
 * @var string $attribute
 * @var array $tree_data
 */
use yii\bootstrap\Html;
?>

<div class="widget-group-checkbox-tree-check">
    <?php foreach ($tree_data as $k => $v): ?>
        <?php if ($v['childrens']): ?>
            <h5><label><?= Html::checkbox($model->formName() . "[{$attribute}][]", $v['checked'], ['value' => $v['value']]); ?><?= $v['name'] ?></label></h5>
            <div class="" style="padding-left: 2em;">
                <?=$this->render('tree-check', [
                    'tree_data' => $v['childrens'],
                    'model' => $model,
                    'attribute' => $attribute,
                ]) ?>
            </div>
        <?php else: ?>
            <?php if($v['parallelNodeHasChildrens']): ?>
                <h5><label><?= Html::checkbox($model->formName() . "[{$attribute}][]", $v['checked'], ['value' => $v['value']]); ?><?= $v['name'] ?></label></h5>
            <?php else: ?>
                <div class="checkbox-line">
                    <label class="pull-left" style="min-width: 3em;padding-right: 2em;">
                        <?= Html::checkbox($model->formName() . "[{$attribute}][]", $v['checked'], ['value' => $v['value']]); ?><?= $v['name'] ?>
                    </label>
                </div>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
    <div class="clearfix"></div>
</div>
